package com.linkwings.dbTemp;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


public class FileUtil{

	 public static void copyFile(File from, File to){
  	 FileInputStream in = null;
  	 FileOutputStream out = null;
  	 try{
	  	 in = new FileInputStream(from);
	  	 out = new FileOutputStream(to);

	  	 byte bt[] = new byte[1024];
		    int c;
		    while ( (c = in.read(bt)) > 0) {
		    	out.write(bt, 0, c);
		    }
  	 }catch(Exception e){
  		 e.printStackTrace();
  	 }finally{
  			try {
  				 if(in!=null){
  					 in.close();
  				 }
  				 if(out!=null){
  					 out.close();
  				 }
        } catch ( IOException e ) {
	        e.printStackTrace();
        }

  	 }
   }


	 public static List<String> readFileOfList(String path){
			List<String> list = new ArrayList<String>();
			try{
				InputStreamReader ir = new InputStreamReader(new FileInputStream(path),"UTF8");
				BufferedReader br = new BufferedReader(ir);
				String data = br.readLine();

				while(data!=null){
					list.add(data);
					data = br.readLine();
				}
				br.close();
				ir.close();
			}catch(Exception e){
				e.printStackTrace();
			}
			return list;
		}

}
